﻿using System;

namespace Teleware.Newbe.Navigation.Web.Common
{
    public static class EnumsHelper
    {
        public static T ConvertToEnum<T>(string source)
        {
            var values = Enum.GetValues(typeof(T));
            foreach (var value in values)
            {
                if (value.ToString() == source)
                {
                    return (T)value;
                }
            }
            throw new ArgumentOutOfRangeException(nameof(source));
        }
    }
}
